const util = require('utils/util.js')
//app.js
App({
  onLaunch: function () {
    wx.request({
      url: util.url + 'season_info',
      success: res => {
        //console.log(res);
        this.globalData.seasonInfo = res.data;
        if(this.seasonInfoCallback)
        {
          this.seasonInfoCallback(res);
        }
      }
    })
  },

  /**
   * 请求收藏信息
   */
  onRequestFollowInfo: function () {
    wx.request({
      url: util.url + 'user_followInfo',
      data: {
        unionId: this.globalData.unionId
      },
      success: res => {
        console.log("请求收藏信息");
        //console.log(res);
        //this.globalData.followInfo = res.data;
        for (let i = 0; i < res.data.length;i++)
        {
          this.globalData.followInfo[res.data[i].season_id] = res.data[i].follow_type;
        }
        console.log(this.globalData.followInfo);
        if (this.followInfoCallback) {
          this.followInfoCallback(res);
        }
      }
    })
  },
  
  globalData: {
    userInfo: null,
    //番剧总表
    seasonInfo:null,
    //收藏列表
    followInfo:{},
    //登录临时token
    loginCode:null,
    unionId:null
  }
})